<?php
/**
 * Класс отвечает за вывод результатов поиска по сайту
 *  
 * @see Google Search JSON API
 * @author Гринько Виталий <vitalygrinko@gmail.com>
 * @version 1.0
 */
class View_Search {
  
  public static function showResults ($arrResults, $query, $spltPageNum) {
    if (empty($arrResults) && strlen($query)) {
      echo '<div id="search_not_found">
              Не найдено ни одного документа, соответствующего запросу <strong>' . $query . '</strong>. 
            </div>';
      return;
    }
    echo '<ol id="google_search_results" start="' . (($spltPageNum-1)*16+1) . '">';
    foreach($arrResults as $searchresult) {
      if($searchresult['GsearchResultClass'] == 'GwebSearch') {
        echo '
          <li>
            <div class="search_result_title"><a href="' . $searchresult['unescapedUrl'] . '">' . $searchresult['titleNoFormatting'] . '</a></div>
            <p class="search_result_context">' . $searchresult['content'] . '</p>
          </li>';
      }
    }
    echo '</ol>';
  }
  
  
  public static function showForm($query) {
    echo '<div></div><br />';
		echo '<div class="rounded_box" id="searchFormBox">';
			echo '<div class="rounded_box_bottom">';
  			echo '<div class="rounded_box_right">';
	  			echo '<div class="rounded_box_left">';
		  			echo '<div class="rounded_box_right_top">';
			  			echo '<div class="rounded_box_right_bootom">';
				  			echo '<div class="rounded_box_left_bottom">';
					  			echo '<div class="rounded_box_left_top"  id="searchFormArea">';
					  			
                    echo '<form method="GET">';
                      echo '<input type="text" id="query" name="q" value="' . $query . '" />';
                      echo '<input type="image" src="' . W_IMAGES . 'button/btn_search.gif" name="sbmtSearch" id="sbmtSearch">';
                      echo '<span class="poweredBy">Powered by <a href="http://google.com/" title="Google"><span class="b">G</span><span class="r">o</span><span class="y">o</span><span class="b">g</span><span class="g">l</span><span class="r">e</span></a></span>';
                    echo '</form>';
                  
                    echo '</div>';
                echo '</div>';
              echo '</div>';
            echo '</div>';
          echo '</div>';
        echo '</div>';
      echo '</div>';
    echo '</div>';
  }
}
?>